package com.aloda.controller.admin;

import com.aloda.dto.OperationLogPageDTO;
import com.aloda.entity.OperationLog;
import com.aloda.result.PageResult;
import com.aloda.result.Result;
import com.aloda.service.OperationLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/admin/log")
public class OperationLogController {

    @Autowired
    private OperationLogService operationLogService;

    /**
     * 操作日志分页查询
     * @param pageDTO
     * @return
     */
    @PostMapping("/list")
    public Result page(@RequestBody OperationLogPageDTO pageDTO){
        log.info("操作日志分页查询：{}",pageDTO);
        PageResult pageResult = operationLogService.pageQuery(pageDTO);
        return Result.success(pageResult);
    }

    /**
     * 删除操作日志
     * @param ids
     * @return
     */
    @DeleteMapping("/delete")
    public Result delete(@RequestBody List<Long> ids){
        log.info("删除操作日志：{}",ids);
        operationLogService.delete(ids);
        return Result.success();
    }
}
